#ifndef __PID_H_
#define __PID_H_	

#include "main.h"    //调用之因:main.h中调用了stm32f1xx_hal.h(HAL库封装函数库),故调main.h,也间接调用了HAL封装函数库.

// PID控制器结构体
typedef struct {
    float kp;
    float ki;
    float kd;
    float ek;  //当前误差
    float ek1; //前一次误差e(k-1)
    float ek2; //前前次误差e(k-2)
    float location_sum;  //;位置式PID 积分
    float out;	
} PIDController;

float PID_location(float setvalue, float actualvalue,PIDController *PID);
float PID_increment(float setvalue, float actualvalue,PIDController *PID);

int16_t Left_pwm_PID(int16_t setspeed,int16_t encoder);
int16_t Right_pwm_PID(int16_t setspeed,int16_t encoder);






#endif
